﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using Server.Models;
using Server.Share;

namespace Server.Controllers
{
    [RoutePrefix("51API/Login")]
    public class LoginController : ApiController
    {
        CShare comm = new CShare();
        [Route("UserLogin")]
        public IHttpActionResult PostUserLogin(UserInfo userInfoModel)
        {
            try
            {
                UserLoginModel ul = comm.cUserCtrl.UserLogin(userInfoModel);
                RetModel ret = new RetModel
                {
                    Data = ul,
                    ErrCode = "",
                    ErrInfo = "",
                    Success = true
                };
                return Ok(ret);
            }
            catch (Exception ex)
            {
                return Ok(new RetModel { Success = false, ErrCode = "Login001", ErrInfo = ex.Message, Data = null });
            }
        }
        [Route("UserLoginOut")]
        public IHttpActionResult PostUserLoginOut(string UName)
        {
            try
            {
                RetModel ret = new RetModel
                {
                    Data = null,
                    ErrCode = "",
                    ErrInfo = "",
                    Success = true
                };
                return Ok(ret);
            }
            catch (Exception ex)
            {
                return Ok(new RetModel { Success = false, ErrCode = "Login002", ErrInfo = ex.Message, Data = null });
            }
        }
        [Route("UserPassEdit")]
        public IHttpActionResult PostUserPassEdit(string oldPass, string newPass)
        {
            try
            {
                RetModel ret = new RetModel
                {
                    Data = null,
                    ErrCode = "",
                    ErrInfo = "",
                    Success = true
                };
                return Ok(ret);
            }
            catch (Exception ex)
            {
                return Ok(new RetModel { Success = false, ErrCode = "Login003", ErrInfo = ex.Message, Data = null });
            }
        }
    }
}